<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
		<title>学生信息管理中心</title>
		<link rel="shortcut icon"href="./ico/ooopic_1500625526.ico">
		<link href="./bootstrap/css/bootstrap.css" rel="stylesheet">
		<script type="text/javascript" src="./jquery/jquery.min.js"></script>
		<script type="text/javascript" src="./jquery/validate.js"></script>
		<script type="text/javascript" src="./bootstrap/js/bootstrap.js"></script>
		<script type="text/javascript" src="./js/isLogin.js"></script>
		<style type="text/css">
			h1{
				font-size:40px;
			    text-shadow: 5px 5px 5px #87c3ff;
			}
			.error{
				color: red;
			}
		</style>
	</head>
	<body>
		<div class="container">
			<h1 class="text-center">学生信息管理中心</h1>
			<br>
			<center>
				<table class="table table-bordered text-center" style="height:85%;">
					<tbody>
						<tr>
							<td style="width:20%;height:80%;background-color:#87c3ff">
								<br><br><br><br>
								<div class="text-left" id="notLogin">
									<!-- 账号输入空格无效 -->
									<b>&nbsp;&nbsp;账号：</b><br>
									&nbsp;<input type="text" id="account" name="account" onkeypress="javascript:
										if(event.keyCode == 32)
											event.returnValue = false;"><br>
									<div class="error" id="notAccount">
										
									</div>
									<b>&nbsp;&nbsp;密码：</b><br>
									&nbsp;<input type="password" id="password" name="password"><br>
									<div class="error" id="notPassword">
										
									</div>
									<br>
									&nbsp;<input type="button" class="btn-default" onclick="login()" value="管理员登录"><br>
									<br>
									<p class="alert alert-warning">
										管理员需要登录后才可以对学生信息进行管理。
									</p>
								</div>
								<div id="login">
									<a href="./html/student_insert.html" target="iframe">
										<input type="button" class="btn-default" value=" 新增学生信息 ">
									</a><br>
									<br>
									<a href="./html/admin_update.html" id="admin_update" target="iframe">
										<input type="button" class="btn-default" value=" 修改个人信息 ">
									</a><br>
									<br>
									<input type="button" class="btn-default" onclick="logOff()" value="    退出登录    "><br>
									<br>
									<p class="alert alert-warning text-left">
										您现在可以对学生信息进行管理了，查询学生信息后，点击头像就可以进行管理。
									</p>
								</div>
							</td>
							<td style="width=80%;height=100%">
								<nav class="navbar" style="width:100%;height:100%;" role="navigation">
									<div class="container-fluid">
										<div class="navbar-header">
											<a class="navbar-brand" href="./html/home.html" id="home" target="iframe">
												<b style="font-size:30px;">首页</b>
											</a>
										</div>
										<!-- <div>
											<ul class="nav navbar-nav">
												<li><a href="#"></a></li>
											</ul>
										</div> -->
									</div>
									<iframe id="iframe" name="iframe" frameborder="1" style="width:100%;height:90%;" src="./html/home.html"></iframe>
								</nav>
							</td>
						</tr>
					</tbody>
				</table>
			</center>
		</div>
	</body>
	<script>
		//判断是否已经登录
		$(function(){
			$("#login").hide();
			$("#notLogin").hide();
			if(isLogin(".") == 1){
				$("#login").show();
			}
			else{
				$("#notLogin").show();
			}
		});
		//登录
		function login(){
			var account = $("#account").val();
			var password = $("#password").val();
			$("#notAccount").html("");
			$("#notPassword").html("");
			if(account == ""){
				$("#notAccount").append("&nbsp;请输入账号！");
			}
			if(password == ""){
				$("#notPassword").append("&nbsp;请输入密码！");
			}
			if(account != "" && password != ""){
				var sql = "select * from administrator where account = '"+ account +"';";
				$.ajax({
					url:'./php/config/db_connect.php',
					type:'post',
					async:false,
					dataType:'json',
					data:{
						sql: sql,
						operation: "select",
						db_table: "administrator",
						password: password
					},
					success:function(data){
						if(data.result == 0){
							$("#notPassword").append("&nbsp;" + data.status);
						}
						else if(data.result == 1){
							$("#notLogin").hide();
							$("#login").show();
							document.getElementById("account").value="";
							document.getElementById("password").value="";
							document.getElementById("home").click();
						}
					},
					error:function(status,error){
						alert("error：登录失败! "+status+"! "+error+"! ");
					},
				});
			}
		}
		//退出登录
		function logOff(){
			var r=confirm("退出登录将不能管理学生信息，确认退出登录？");
			if (r==true){
				$.ajax({
					url:'./php/logOff.php',
					type:'post',
					async:false,
					success:function(){
						$("#notLogin").show();
						$("#login").hide();
						//返回首页
						document.getElementById("home").click();
					},
					error:function(status,error){
						alert("error："+status+"! "+error+"! ");
					},
				});
			}
		}
	</script>
</html>